package com.kk.emp.common;
/*
 *@author KK on 2022.10.08 0:45
 */

import com.kk.emp.entity.Emp;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class LoginInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        Emp emp = (Emp) request.getSession().getAttribute(Const.IS_LOGIN);
        if (emp == null) {
            response.sendRedirect(request.getContextPath()+"/login.jsp");
            return false;
        } else {
            return true;
        }
    }
}
